<%-- 
    Document   : TerimaBrgSupppcontrol
    Created on : Dec 3, 2013, 8:42:55 PM
    Author     : predator
--%>

<%@page import="Bean.TerimaBrgKc"%>
<%@page import="Bean.stock"%>
<%@page import="java.util.List"%>
<%@page import="java.util.logging.Logger"%>
<%@page import="java.util.logging.Level"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.Statement"%>
<%@page import="Bean.DataBaseConnection"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Halaman Utama</title>
    </head>
    <body>
        <form action="TerimaBrgSuppp.jsp" method="post">
            <%@ page errorPage="Errorisi.jsp"%>
            <%
                int x = 10 / 1;%>
            <%
                Bean.TerimaBrgKc terimabrgkc = (Bean.TerimaBrgKc) session.getAttribute("terimabrgkc");
                if (terimabrgkc == null) {
                    terimabrgkc = new Bean.TerimaBrgKc();
                    session.setAttribute("terimabrgkc", terimabrgkc);
                }



                terimabrgkc.setKodetoko((String) request.getParameter("KodeToko"));
                terimabrgkc.setKodebarang((String) request.getParameter("KodeBarang"));
                terimabrgkc.setNama((String) request.getParameter("nama"));
                terimabrgkc.setJumlah(Integer.parseInt(request.getParameter("jumlah")));
                terimabrgkc.setTglterima((String) request.getParameter("tglTerima"));
                terimabrgkc.setHarga(Integer.parseInt(request.getParameter("harga")));

                Connection conn = null;

                try {
                    conn = DataBaseConnection.open("jdbc:oracle:thin:@172.23.9.185:1521:orcl", "mhs115314009", "mhs115314009");
                    Statement statement = conn.createStatement();
                    String sql = "insert into transaksiterimakc values ('" + terimabrgkc.getKodetoko() + "','" + terimabrgkc.getKodebarang() + "'," + terimabrgkc.getJumlah() + ",'" + terimabrgkc.getTglterima() + "'," + terimabrgkc.getHarga() + ")";
                    String sql2 = "update stock set jumlah=jumlah+" + terimabrgkc.getJumlah() + " where kode_barang='" + terimabrgkc.getKodebarang() + "'";
                    String sql4 = "insert into stock values ('" + terimabrgkc.getKodebarang() + "'," + terimabrgkc.getJumlah() + ")";
                    String sql3 = "insert into barangrplt values ('" + terimabrgkc.getKodebarang() + "','" + terimabrgkc.getNama() + "'," + terimabrgkc.getHarga() + ")";
                    statement.executeQuery(sql);
                    statement.executeQuery(sql2);
                    statement.executeQuery(sql3);
                    statement.executeQuery(sql4);
                    conn.close();
                } catch (SQLException ex) {
                    Logger.getLogger(DataBaseConnection.class.getName()).log(Level.SEVERE, null, ex);
                }
            %>
        </form>
        <table width="1024" height="788" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td height="181" colspan="2" align="center" valign="top" bgcolor="#D5EDB3" scope="col"><p>&nbsp;</p>
                    <p><font size="24" >TOKO MERAH<font><br />
                        <font size="5" >Menjual Berbagai Kebutuhan<font> <br />
                    </p>
                </td>
            </tr>
            <tr>
                <td width="256" align="left" valign="top" bgcolor="#5C743D" scope="row">
                    <br><br>&nbsp;&nbsp;&nbsp;<a href="TerimaBrgSuppp.jsp"><strong>TERIMA BARANG SUPPLIER</strong> </a>
                    <br><br>&nbsp;&nbsp;&nbsp;<a href="TerimaBrgKc.jsp"><strong>TERIMA BARANG KC</strong> </a>
                    <br><br>&nbsp;&nbsp;&nbsp;<a href="PesanBrgKc.jsp"><strong>PESAN BARANG KE KC</strong> </a>
                    <br><br>&nbsp;&nbsp;&nbsp;<a href="penjualantoko.jsp"><strong>PENJUALAN BARANG</strong> </a>
                    <br><br><br><br>&nbsp;&nbsp;&nbsp;<a href="Login.jsp"><strong>LOGOUT</strong> </a></td>
                <td width="752" align="center" valign="top" bgcolor="#FFFFCC" scope="row"><p>&nbsp;</p>
                    <%
                        TerimaBrgKc terimakc = new TerimaBrgKc();
                        List<TerimaBrgKc> listterimakc = terimakc.lihatbarang();
                    %>
                    <p>Tabel Transaksi Terima Barang Dari Kantor Cabang: </p>
                    <table align="center" width="463" height="75" border="0">
                        <tr>
                            <th bgcolor="#999999" width="113"><div align="center">Kode Toko</div> </th>
                        <th bgcolor="#999999" width="113"><div align="center">Kode Barang</div> </th>
                        <th bgcolor="#999999" width="56"><div align="center">Jumlah</div></th>
                        <th bgcolor="#999999" width="56"><div align="center">Harga Satuan</div></th>
                        <th bgcolor="#999999" width="159"><div align="center">Tanggal Terima </div></th>
            </tr>
            <tr>
                <%

                    for (TerimaBrgKc term : listterimakc) {
                %>
                <td bgcolor="#FFFFFF"><div align="center"><%=term.getKodetoko()%></div></td>
                <td bgcolor="#FFFFFF"><div align="center"><%=term.getKodebarang()%></div></td>
                <td bgcolor="#FFFFFF"><div align="center"><%=term.getJumlah()%></div></td>
                <td bgcolor="#FFFFFF"><div align="center"><%=term.getHarga()%></div></td>
                <td bgcolor="#FFFFFF"><div align="center"><%=term.getTglterima()%></div></td>
            </tr>
            <%
                }
            %>
        </table>

    </table>
    <p><a href="TerimaBrgSuppp.jsp">Kembali Ke Form</a> </p>
</td>
</tr>
</table>

</td>
</tr>
</table>
</body>
</html>
